import 'package:boss/models/takeout_order_list_data.dart';
import 'package:json_annotation/json_annotation.dart';

part 'reback_order_list_data.g.dart';

@JsonSerializable()
class RebackOrderListData extends Object {
  @JsonKey(name: 'total')
  int total;

  @JsonKey(name: 'totalPage')
  int totalPage;

  @JsonKey(name: 'items')
  List<RebackOrderItem> items;

  RebackOrderListData(
    this.total,
    this.totalPage,
    this.items,
  );

  factory RebackOrderListData.fromJson(Map<String, dynamic> srcJson) => _$RebackOrderListDataFromJson(srcJson);

  Map<String, dynamic> toJson() => _$RebackOrderListDataToJson(this);
}

@JsonSerializable()
class RebackOrderItem extends Object {
  @JsonKey(name: 'refundId')
  String refundId;

  @JsonKey(name: 'storeId')
  int storeId;

  @JsonKey(name: 'userId')
  int userId;

  @JsonKey(name: 'rebackAmount')
  int rebackAmount;

  @JsonKey(name: 'takeOutId')
  String takeOutId;

  @JsonKey(name: 'type')
  int type;

  @JsonKey(name: 'status')
  int status;

  @JsonKey(name: 'backImage')
  String backImage;

  @JsonKey(name: 'backReason')
  String backReason;

  @JsonKey(name: 'rejectReason')
  String rejectReason;

  @JsonKey(name: 'ctime')
  String ctime;

  @JsonKey(name: 'utime')
  String utime;

  @JsonKey(name: 'refundMoneyOrderDetailList')
  List<RefundMoneyOrderDetailList> refundMoneyOrderDetailList;

  String contactName;

  String phoneNum;

  String get statusText {
    if (status == 0) {
      return '待退款';
    }

    if (status == 1) {
      return '已退款';
    }

    if (status == 2) {
      return '拒绝退款';
    }

    return '';
  }

  RebackOrderItem(
    this.refundId,
    this.storeId,
    this.userId,
    this.rebackAmount,
    this.takeOutId,
    this.type,
    this.status,
    this.backImage,
    this.backReason,
    this.rejectReason,
    this.ctime,
    this.utime,
    this.refundMoneyOrderDetailList,
    this.contactName,
  );

  factory RebackOrderItem.fromJson(Map<String, dynamic> srcJson) => _$RebackOrderItemFromJson(srcJson);

  Map<String, dynamic> toJson() => _$RebackOrderItemToJson(this);
}

@JsonSerializable()
class RefundMoneyOrderDetailList extends Object {
  @JsonKey(name: 'id')
  int id;

  @JsonKey(name: 'userId')
  int userId;

  @JsonKey(name: 'refundId')
  String refundId;

  @JsonKey(name: 'takeOutId')
  String takeOutId;

  @JsonKey(name: 'orderDetailId')
  int orderDetailId;

  @JsonKey(name: 'num')
  int num;

  @JsonKey(name: 'totalFee')
  int totalFee;

  @JsonKey(name: 'backFee')
  int backFee;

  @JsonKey(name: 'packFee')
  int packFee;

  @JsonKey(name: 'ctime')
  String ctime;

  @JsonKey(name: 'utime')
  String utime;

  @JsonKey(name: 'takeOutOrderDetail')
  TakeOutOrderDetails takeOutOrderDetail;

  RefundMoneyOrderDetailList(
    this.id,
    this.userId,
    this.refundId,
    this.takeOutId,
    this.orderDetailId,
    this.num,
    this.totalFee,
    this.backFee,
    this.packFee,
    this.ctime,
    this.utime,
    this.takeOutOrderDetail,
  );

  factory RefundMoneyOrderDetailList.fromJson(Map<String, dynamic> srcJson) => _$RefundMoneyOrderDetailListFromJson(srcJson);

  Map<String, dynamic> toJson() => _$RefundMoneyOrderDetailListToJson(this);
}
